Repository navigation
fix(mcp-server): honour task ttl and test not-found after session close - #1671
Merged
smart-ssh-coordinator[bot] merged 2 commits intoDec 4, 2026
Merged
smart-ssh-coordinator[bot] merged 2 commits into
smart-ssh-coordinator[bot] merged 2 commits into
Conversation
…se (#1660) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
6 tasks
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
6 tasks
There was a problem hiding this comment.
Review
Verdict: approved
Review level: elevated
Blocking
None.
Non-blocking
docs/specs/0028-mcp-server-integration.md§10a,Completedsentence: the example "(etwa weil es schon ohne Start fertig ist)" is vague. In the code,Completedarises when the outcome isApprovedbut no command handle was handed over:Approval::Other, the action id not yet known in the MCP backend, or no approval signal at all (tool_server.rsresolve_pending_decision). The main statement (approved, no access, carries the final result like the built-in tool) matchesoutcome_to_tool_result, so this is wording only.- Open PR #1672 also edits
task_status/cancel_taskincrates/mcp-server/src/extension.rs. Whichever PR merges second will need a textual merge. They don't conflict in substance.
Verified
- files read: 2/2 logic files (
crates/mcp-server/src/extension.rs,crates/mcp-server/tests/tasks.rs), complete diff, plus the spec and changelog fragment - counter-proof (executed): I disabled the expiry check in
task_owner.test_task_expires_after_its_ttl_without_asking_the_extensionfailed and passed again after the restore. I removed theretaininanswer_as_task.test_registering_a_task_drops_expired_entriesfailed and passed again after the restore. I removed theretaininnotify_session_closed.tests/tasks.rs:test_task_of_a_closed_session_is_not_found_and_the_extension_is_not_calledfailed and passed again after the restore. - AC mapping (read):
- AC1 →
extension.rs:test_task_expires_after_its_ttl_without_asking_the_extension(at the ttl, get gives None and cancel gives false, hook count stays 2) - AC2 → same test at ttl − 1 ms (both reach the hook)
- AC3 →
test_registering_a_task_drops_expired_entries(count is 2, stays 2 with no registration, drops to 1 after a registration) - AC4 →
tests/tasks.rs:test_task_of_a_closed_session_…(asserts -32602 for get and cancel on 2026-07-28,status_ctxunchanged,cancelledempty) - AC5 → spec §10a and §10 updated
- tasks without a ttl:
test_task_without_ttl_is_kept
- AC1 →
- edge cases (read):
- ttl 0 → expires at once (
>=), ok ttlMs = u64::MAX→Duration::from_millisplussaturating_duration_since, nothing added, so no overflow; ok- re-registering an id whose entry expired →
retainruns before the duplicate check, so the id is accepted; ok - duplicate of a live id → still rejected; ok
- lookup of another client's expired id → entry removed and not-found returned, same answer as before; ok
- lock never held across an await; ok
- ttl 0 → expires at once (
- callers checked:
answer_as_task(1 production call site,tool_server.rs:465),task_owner(2, both internal),notify_session_closed(app-shell/src/sessions.rs:95, behaviour unchanged) → ok - tests run locally:
cargo test --locked -q -p mcp-server→ 62 passed (executed).cargo clippy --locked -p mcp-server --all-targets -- -D warningsandcargo fmt --all --checkwere clean (executed). - CI: all checks green (
gh pr checks 1671) - UI: not a UI change
- data: not touched (in-memory map only)
Timing analysis
- 2 test files analysed: no timing dependency found. The unit tests use
start_paused = truewithtokio::time::Instantin the code under test, so the boundary check is exact. The integration test closes the session directly, without sleeps or fixed ports.
Spec
- visible behaviour changed: an MCP task becomes not-found once its
ttlMshas elapsed. Tasks without a ttl stay until the session closes. - spec searched:
rg -il 'ttlMs|tasks/get|Aufgabe' docs/specs/→ 0028 §10a covers this area - verdict: the spec change is present and matches the code (§10a ttl and lazy expiry,
Completeddecision, §10 test cases). The changelog fragment is present, in English, with the version andCHANGELOG.mdunchanged.
Security checks
- The owner check (
owner.session.client != caller.session.client) is unchanged. The expiry check only adds a not-found path before it, so it is narrower and not a loosening. - Loosening check against
origin/developforextension.rs: no condition removed. Every new path returns not-found or drops an entry. Without the extension being asked, no path grants access. - Bypass attempts:
- a foreign client probing an expired id
- ttl 0
- a huge ttl
- re-using an id after expiry
- a duplicate live id
None of these reaches another client's task or skips the confirmation. The task path never touches FilterEngine or the confirmation flow.
Threat model: no change – only forgets task ids earlier; owner check unchanged: reason holds, CIthreat-model-notegreen.
Manual checks pending
None.
Follow-ups
None.
smart-ssh-coordinator
Bot
deleted the
issue-1660-mcp-tasks-honour-ttl-test-not-found
branch
December 4, 2026 10:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1660
Summary
MCP task bookkeeping now honours the task's
ttlMs(measured from creation, lazily on lookup and on registration; no timer). Tasks without ttl stay until the session closes. Spec 0028 §10a describes ttl and theCompleteddecision.Acceptance Criteria
extension.rs:test_task_expires_after_its_ttl_without_asking_the_extension)extension.rs:test_registering_a_task_drops_expired_entries; no sweep without registration); no-ttl kept:test_task_without_ttl_is_kepttests/tasks.rs:test_task_of_a_closed_session_is_not_found_and_the_extension_is_not_called)Completed: metcargo test -p mcp-server, clippy clean); CI belowTests
Counter-proof: disabling the expiry check on lookup makes the ttl test fail.
Assumptions
Owner check on the client is unchanged. Timing uses
tokio::time::Instantso tests run with paused time.Spec
updated 0028
Threat model: no change – only forgets task ids earlier; owner check unchanged.
Follow-ups
None.
🤖 Generated with Claude Code